package com.webank.webase.chain.mgr.repository.bean;

import java.io.Serializable;
import java.util.Date;
import com.webank.webase.chain.mgr.base.enums.DataStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@ToString
@NoArgsConstructor
@EqualsAndHashCode
public class TbNode implements Serializable {

    public static TbNode init(int chainId, String nodeId, String nodeName, int groupId, String ip, int p2pPort, String description, DataStatus dataStatus) {
        Date now = new Date();
        TbNode node = new TbNode();
        node.setNodeId(nodeId);
        node.setChainId(chainId);
        node.setGroupId(groupId);
        node.setNodeName(nodeName);
        node.setNodeIp(ip);
        node.setP2pPort(p2pPort);
        node.setBlockNumber(0L);
        node.setPbftView(0L);
        node.setNodeActive(dataStatus.getValue());
        node.setDescription(description);
        node.setCreateTime(now);
        node.setModifyTime(now);
        return node;
    }

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.node_id
     *
     * @mbg.generated
     */
    private String nodeId;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.chain_id
     *
     * @mbg.generated
     */
    private Integer chainId;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.group_id
     *
     * @mbg.generated
     */
    private Integer groupId;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.node_name
     *
     * @mbg.generated
     */
    private String nodeName;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.node_type
     *
     * @mbg.generated
     */
    private String nodeType;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.node_ip
     *
     * @mbg.generated
     */
    private String nodeIp;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.p2p_port
     *
     * @mbg.generated
     */
    private Integer p2pPort;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.block_number
     *
     * @mbg.generated
     */
    private Long blockNumber;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.pbft_view
     *
     * @mbg.generated
     */
    private Long pbftView;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.node_active
     *
     * @mbg.generated
     */
    private Byte nodeActive;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.description
     *
     * @mbg.generated
     */
    private String description;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.create_time
     *
     * @mbg.generated
     */
    private Date createTime;

    /**
     *
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column tb_node.modify_time
     *
     * @mbg.generated
     */
    private Date modifyTime;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database table tb_node
     *
     * @mbg.generated
     */
    private static final long serialVersionUID = 1L;
}
